package cn.jaye.fabric.application;

import cn.jaye.fabric.application.command.mchaincode.InfoMChaincodeCommand;
import cn.jaye.fabric.application.command.mchaincode.ListMChaincodeCommand;
import cn.jaye.fabric.common.constants.mapping.Table;
import cn.jaye.fabric.domain.model.ChainCode;
import cn.jaye.fabric.domain.model.MChainCode;
import cn.jaye.fabric.domain.repository.ChainCodeRepository;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Jaye
 * @create 2018-05-25 13:58
 */
@Service
public class MChainCodeApplicationService {

    @Autowired
    private ChainCodeRepository chainCodeRepository;

    public List<MChainCode> list(ListMChaincodeCommand listMChaincodeCommand) {
        return chainCodeRepository.selectList(new EntityWrapper<MChainCode>());
    }

    public MChainCode info(InfoMChaincodeCommand infoMChaincodeCommand) {
        return chainCodeRepository.selectOne(new EntityWrapper<MChainCode>().eq(Table.ChainCode.chaincodeId.getFieldValue(), infoMChaincodeCommand.getChaincodeId()));
    }
}
